<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/"
          xmlns:xi="http://www.w3.org/2001/XInclude" lang="en">
        <!-- Simple genshi template for walking the leonardo file system -->

         <!--! This is the site layout -->
        <xi:include href="page.html" />
        <xi:include href="directory.html"/>
        
        <head>
        <!-- We'll be using the javascript helpers later, so let's make sure we have them -->
        ${Markup(h.javascript_include_tag(builtins=True))}
        </head>
        <body>
            <div class="mainPage">
                <h4> ${c.title or c.path} </h4>
                <div py:replace="directory(c.files,c.dirs)"/>
                <div py:if="c.content">${Markup(c.content)}</div>
                <span py:if="c.categories" py:replace="categories(c.categories)"/>
                <h4 py:if="c.askCommments!='NO' or c.askTrackBack!='NO'"> Reactions </h4>
                <p py:if="c.askTrackBack">
                  You can trackback to <a href="${g.site_url+h.url_for()}">this page</a>!
                </p>
                <p py:choose="c.askComments">
                    <p py:when="'READONLY'">Comments are currently readonly</p>     
                    <p py:when="'NO'"> Comments are not allowed on this entry </p>
                </p>
                <div py:if="c.reactions">
                    <div py:for="r in c.reactions">
                        <div class="reactionhdg">
                            <?python 
                            url=r['url']
                            if url.startswith('http'):
                                pass
                            else: 
                                if url!='':url='http://'+url
                            ?>
                            <p>
                                <span py:choose="">
                                    <span py:when="url==''">${r['author']} on ${r['date']}</span>
                                    <span py:otherwise=""><a rel="nofollow" href="$url">${r['author']}</a></span>
                                </span> on ${r['date']} (<a href="#${r['time']}">${r['timeOfDay']})</a>
                            </p>
                        </div>
                        <div class="reaction">${r['content']}</div>
                    </div>
                </div>  
                <div py:if="c.askComments=='YES'">
                    <?python
                    # we need to set up the math captcha if required  
                    if g.math_prompt:
                        import random,md5
                        i,j=random.randint(0,100),random.randint(0,100)
	                o=md5.new()
	                o.update(str(i+j))
	                math_verify=o.hexdigest()
	                math_i,math_j=str(i),str(j)
                    ?>
                    <div id="commentForm">
                        <h4>Add a Comment </h4>
                        <p><form class="add_comment" action="" method="post">
                              <table class="coloured">
                                <tr py:if="g.math_prompt">
                                    <th> What is ${math_i} + ${math_j}?</th>
                                    <td><input type="text" name="math_answer"/>
                                        <input type="hidden" name="math_verification" value="$math_verify"/>
                                    </td>
                                </tr>
                                <tr><th>Name</th><td><input type="text" name="author_name"/></td></tr>
                                <tr><th>URI</th><td><input type="text" name="author_link"/></td></tr>
                                <tr><th>Comment</th><td>
                                        <textarea name="comment_content" rows="10" cols="60"></textarea>
                                </td></tr>
                                <tr><td colspan="2"><input type="submit" value="Submit comment"/></td></tr>
                                <tr><td colspan="2"> Comments are text only.</td></tr>
                                <tr py:if="g.math_prompt"><td colspan="2">
                                    The math question is to ensure you are a human! 
                                </td></tr>
                              </table>
                        </form></p>
                    </div><!-- End of CommentForm -->
                </div>
            </div>
        </body>
    </html>
